/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * POS_PaymentSelect.java
 *
 * Created on Apr 4, 2011, 6:37:46 PM
 */

package POS_Source;

import POS_Controller.POSController;
import Session.POS_SessionManager;
import Utilities.MoneyFormatter;

/**
 * this class renders select payment method view 
 * @author edaype
 * @see POS_Source
 */
public class POS_PaymentSelect extends javax.swing.JPanel {

    private POSController controller;
    private MoneyFormatter moneyFormat;
    /**
     * constructor for this class
     * @param control
     */
    public POS_PaymentSelect(POSController control) {
        controller = control;
        moneyFormat = new MoneyFormatter();
        initComponents();
        customInit();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        InstructionsLabel = new javax.swing.JLabel();
        MainPanel = new javax.swing.JPanel();
        CashButton = new javax.swing.JButton();
        CardButton = new javax.swing.JButton();
        PaidPanel = new javax.swing.JPanel();
        MoneyPaidLabel = new javax.swing.JLabel();
        PaidLabel = new javax.swing.JLabel();
        DuePanel = new javax.swing.JPanel();
        MoneyDueLabel = new javax.swing.JLabel();
        DueLabel = new javax.swing.JLabel();
        InstructionsLabel1 = new javax.swing.JLabel();
        TitlePanel = new javax.swing.JPanel();
        TitleLabel = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        InstructionsLabel.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        InstructionsLabel.setText("Select Payment Method");

        MainPanel.setBackground(new java.awt.Color(255, 255, 255));

        CashButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        CashButton.setText("Cash");
        CashButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CashButtonActionPerformed(evt);
            }
        });

        CardButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        CardButton.setText("Card");
        CardButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CardButtonActionPerformed(evt);
            }
        });

        PaidPanel.setBackground(new java.awt.Color(255, 255, 255));

        MoneyPaidLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 24));

        PaidLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 36));
        PaidLabel.setText("Amount Paid");

        javax.swing.GroupLayout PaidPanelLayout = new javax.swing.GroupLayout(PaidPanel);
        PaidPanel.setLayout(PaidPanelLayout);
        PaidPanelLayout.setHorizontalGroup(
            PaidPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PaidPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PaidPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(MoneyPaidLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(PaidLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        PaidPanelLayout.setVerticalGroup(
            PaidPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PaidPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PaidLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(MoneyPaidLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                .addContainerGap())
        );

        DuePanel.setBackground(new java.awt.Color(255, 255, 255));

        MoneyDueLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 24));

        DueLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 0, 36));
        DueLabel.setText("Amount Due");

        javax.swing.GroupLayout DuePanelLayout = new javax.swing.GroupLayout(DuePanel);
        DuePanel.setLayout(DuePanelLayout);
        DuePanelLayout.setHorizontalGroup(
            DuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DuePanelLayout.createSequentialGroup()
                .addContainerGap(21, Short.MAX_VALUE)
                .addGroup(DuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(MoneyDueLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(DueLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18))
        );
        DuePanelLayout.setVerticalGroup(
            DuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DuePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(DueLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(MoneyDueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout MainPanelLayout = new javax.swing.GroupLayout(MainPanel);
        MainPanel.setLayout(MainPanelLayout);
        MainPanelLayout.setHorizontalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(PaidPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CardButton, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 227, Short.MAX_VALUE)
                .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(DuePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CashButton, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        MainPanelLayout.setVerticalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(DuePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(PaidPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 137, Short.MAX_VALUE)
                .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CardButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CashButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        InstructionsLabel1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        InstructionsLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/POS_Source/images/Logo.png"))); // NOI18N
        InstructionsLabel1.setText(" ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(90, 90, 90)
                        .addComponent(MainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(314, 314, 314)
                        .addComponent(InstructionsLabel))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(InstructionsLabel1)))
                .addContainerGap(114, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(InstructionsLabel1)
                .addGap(18, 18, 18)
                .addComponent(InstructionsLabel)
                .addGap(40, 40, 40)
                .addComponent(MainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(86, Short.MAX_VALUE))
        );

        TitlePanel.setBackground(new java.awt.Color(255, 255, 255));

        TitleLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 60));
        TitleLabel.setText("Payment Selection");

        javax.swing.GroupLayout TitlePanelLayout = new javax.swing.GroupLayout(TitlePanel);
        TitlePanel.setLayout(TitlePanelLayout);
        TitlePanelLayout.setHorizontalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TitlePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TitleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 660, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(354, Short.MAX_VALUE))
        );
        TitlePanelLayout.setVerticalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TitlePanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(TitleLabel)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(TitlePanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TitlePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
/**
 * this method handles card button event
 * @param evt
 */
    private void CardButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CardButtonActionPerformed
        controller.CardAmountScreen();
    }//GEN-LAST:event_CardButtonActionPerformed
/**
 * this method handles cash button event
 * @param evt
 */
    private void CashButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CashButtonActionPerformed
        controller.CashPaymentScreen();
    }//GEN-LAST:event_CashButtonActionPerformed
/**
 * this method overrides default view rendering 
 */
    private void customInit(){
        POS_SessionManager smgr = controller.getSessionManager();
        MoneyPaidLabel.setText(moneyFormat.format(smgr.totalPaid()));
        MoneyDueLabel.setText(moneyFormat.format(smgr.totalDue()));
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CardButton;
    private javax.swing.JButton CashButton;
    private javax.swing.JLabel DueLabel;
    private javax.swing.JPanel DuePanel;
    private javax.swing.JLabel InstructionsLabel;
    private javax.swing.JLabel InstructionsLabel1;
    private javax.swing.JPanel MainPanel;
    private javax.swing.JLabel MoneyDueLabel;
    private javax.swing.JLabel MoneyPaidLabel;
    private javax.swing.JLabel PaidLabel;
    private javax.swing.JPanel PaidPanel;
    private javax.swing.JLabel TitleLabel;
    private javax.swing.JPanel TitlePanel;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
